package net;

import java.util.LinkedList;

public class FixedQueue<T> {

    private final int capacity;
    private final Queue<T> queue;

    public FixedQueue(int capacity)
    {
        queue = new Queue<>();
        this.capacity = capacity;
    }

    public T dequeue()
    {
        return queue.dequeue();
    }

    public void enqueue(T t)
    {
        if(queue.enqueue(t))
        {
            if(queue.size() > capacity) queue.dequeue();
        }
    }

    public T peek()
    {
        return queue.peek();
    }

    public int size()
    {
        return queue.size();
    }
}
